{% extends "base.html" %}

{% block title %}归还申请管理{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2>待处理归还申请</h2>
    <div class="table-responsive">
        <table class="table table-hover">
            <thead class="table-light">
                <tr>
                    <th>用户</th>
                    <th>图书</th>
                    <th>借阅日期</th>
                    <th>应还日期</th>
                    <th>申请时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {% for request in requests %}
                <tr>
                    <td>{{ request.submitter.username }}</td>
                    <td>{{ request.borrow_record.book.title }} ({{ request.borrow_record.book.author }})</td>
                    <td>{{ request.borrow_record.borrow_date.strftime('%Y-%m-%d') }}</td>
                    <td>{{ request.borrow_record.due_date.strftime('%Y-%m-%d') }}</td>
                    <td>{{ request.request_time.strftime('%Y-%m-%d %H:%M') }}</td>
                    <td>
                        <form action="{{ url_for('admin.approve_return', request_id=request.id) }}"
                              method="post" class="d-inline">
                            <button type="submit" class="btn btn-sm btn-success">批准</button>
                        </form>
                        <form action="{{ url_for('admin.reject_return', request_id=request.id) }}"
                              method="post" class="d-inline">
                            <button type="submit" class="btn btn-sm btn-danger">拒绝</button>
                        </form>
                    </td>
                </tr>
                {% else %}
                <tr>
                    <td colspan="6" class="text-center text-muted">暂无待处理的归还申请</td>
                </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>
</div>
{% endblock %}
